<link rel="stylesheet" type="text/css" href="/theme/Green/css/Tdevelop.css">
<?php // echo $this->Form->create('Paginate', array('id' => 'paginate', 'url' => $this->request->here(false), 'type' => 'post', 'inputDefaults' => array('label' => false))); ?>           				
<div id="content-header">
	<h1>Quản lý đơn hàng<?php //echo __d('system','Content Management');?></h1>    
</div>
<form action="" class="form-inline wd-select-day">
    <div class="wd-form-group">
        <label for="">Từ ngày</label>
        <input type="text" class="wd-datepicker" id="from-day" value="<?php if($from){ echo $from;}?>">
    </div>
    <div class="wd-form-group second">
        <label for="">Đến ngày</label>
        <input type="text" class="wd-datepicker" id="to-day" value="<?php if($to){ echo $to;}?>">
    </div>
    <button type="button" class="btn btn-success" id="submit-view-day">Xem</button>
</form>
<div class="container-fluid">
<div class="row-fluid">
    <div class="span12">
        <?php $defaultLanguage = Router::defaultLanguage();
            $_queries = array('continue' => $this->request->here(false));
        ?> 	
        <?php echo $this->Session->flash(); ?>
        <div class="widget-box wd-custom-tabs">
            <div class="widget-title">
                <ul class="nav nav-tabs">
                    <li class="active"><a data-toggle="tab" href="#tab1">Đơn hàng mới</a></li>
                    <li><a data-toggle="tab" href="#tab2">Đơn hàng đã xác nhận</a></li>
                    <li><a data-toggle="tab" href="#tab3">Đơn hàng đã thanh toán</a></li>
                    <li><a data-toggle="tab" href="#tab4">Đơn hàng đã nhận</a></li>
                    <li><a data-toggle="tab" href="#tab5">Đơn hàng không xác nhận</a></li>
                </ul>
            </div>
            <div class="widget-content tab-content">
                <div id="tab1" class="tab-pane active">
                    <div class="widget-box widget-content-no-padding">
                        <div class="widget-content widget-content-two">
                            <table class="table table-bordered data-table table-striped wd-hover-btn wd-table-order-management">
                                <thead>
                                    <tr>
                                        <th class="wd-col-1">STT</th>
                                        <th class="wd-col-2">Mã đơn hàng</th>
                                        <th style="text-align:left">Tên khách hàng</th>
                                        <th class="wd-col-4">Giá trị đơn hàng</th>
                                        <th class="">Thời gian tạo</th>
                                        <th class="">Thời gian nhận hàng</th>
                                        <th class="wd-col-6">Thao tác</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <?php $count=1;$sum=0;
                                foreach ($new_orders as $data) {
                                    $sum+=$data['Order']['sum'];?>
                                    <tr>
                                        <td><?php echo $count++?></td>
                                        <td><?php if($data['Order']['code']){echo $data['Order']['code'];}else{ echo $this->Currency->codeOrder($data['Order']['id']);}?></td>
                                        <td style="text-align:left"><?php echo $data['User']['fullname']?></td>
                                        <td><?php echo $this->Currency->formatCurrency($data['Order']['sum'])?> vnđ</td>
                                        <td><?php echo date('G:i d-m-Y',$data['Order']['created'])?></td>
                                        <td><?php echo $data['Order']['time']?></td>
                                        <td>
                                            <ul class="wd-link-control">
                                                <li><a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'order_edit', $data['Order']['id'], '?' => $_queries));?>" class="btn btn-mini">
                                                <i class="icon-edit"></i> <?php echo __d('system','Xem');?></a>
                                                </li>
                                            </ul>
                                        </td>
                                    </tr>
                                <?php }?>
                                </tbody>
                            </table>
                        </div>

                    </div>
                    <div class="row-fluid">
                        <div class="span12 statistics">
                            <p><i class="icon-list-alt"></i> Số lượng đơn hàng: <strong><?php echo ($count-1);?></strong></p>
                            <p><i class="icon-hand-right"></i> Tổng giá trị đơn hàng: <strong><?php echo $this->Currency->formatCurrency($sum).'đ';?></strong></p>
                        </div>
                    </div>
                </div>
                <div id="tab2" class="tab-pane">
                    <div class="widget-box widget-content-no-padding">
                        <div class="widget-content widget-content-two">
                            <table class="table table-bordered data-table table-striped wd-hover-btn wd-table-order-management" id="table-confirmed">
                                <thead>
                                    <tr>
                                        <th class="wd-col-1">STT</th>
                                        <th class="wd-col-2">Mã đơn hàng</th>
                                        <th style="text-align:left">Tên khách hàng</th>
                                        <th class="wd-col-4">Giá trị đơn hàng</th>
                                        <th class="">Thời gian tạo</th>
                                        <th class="">Thời gian nhận hàng</th>
                                        <th class="wd-col-7">Trạng thái</th>
                                        <th class="wd-col-6">Thao tác</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $count=1;$sum=0;
                                    foreach ($confirmed_orders as $data) {
                                            $sum+=$data['Order']['sum'];?>
                                        <tr>
                                            <td><?php echo $count++?></td>
                                            <td><?php if($data['Order']['code']){echo $data['Order']['code'];}else{ echo $this->Currency->codeOrder($data['Order']['id']);}?></td>
                                            <td style="text-align:left"><?php echo $data['User']['fullname']?></td>
                                            <td><?php echo $this->Currency->formatCurrency($data['Order']['sum'])?> vnđ</td>
                                            <td><?php echo date('G:i d-m-Y',$data['Order']['created'])?></td>
                                            <td><?php echo $data['Order']['time']?></td>
                                            <td>
                                                <div class="control-group list-checkbox">
                                                    
                                                    <div class="control-group">
                                                        <label class="control-label wd-mb-10">
                                                            <input type="checkbox" name="radios" class="mtop" id="check-paid-<?php echo $data['Order']['id']?>-1" value="1" />
                                                            Đã thanh toán
                                                        </label>
                                                        <label class="control-label">
                                                            <input type="checkbox" name="radios" class="mtop" id="check-paid-<?php echo $data['Order']['id']?>-2" value="1" />
                                                            Đã nhận hàng
                                                        </label>
                                                    </div>
                                                    
                                                </div>                                                                
                                            </td>
                                            <td>
                                                <ul class="wd-link-control">
                                                    <li><a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => '   node', 'action' => 'order_edit', $data['Order']['id'], '?' => $_queries));?>"       class="btn btn-mini">
                                                        <i class="icon-edit"></i> <?php echo __d('system','Xem');?></a>
                                                    </li>
                                                    <li class="wd-icon-2"><button type="button" id="<?php echo $data['Order']['id']?>" class="btn btn-mini btn-inverse check_paid"><i class="glyphicon icon-save"></i> Lưu</button></li>
                                                </ul>
                                            </td>
                                        </tr>
                                    <?php }?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12 statistics">
                            <p><i class="icon-list-alt"></i> Số lượng đơn hàng: <strong><?php echo ($count-1);?></strong></p>
                            <p><i class="icon-hand-right"></i> Tổng giá trị đơn hàng: <strong><?php echo $this->Currency->formatCurrency($sum) .'đ';?></strong></p>
                        </div>
                    </div>
                </div>
                <div id="tab3" class="tab-pane">
                    <div class="widget-box widget-content-no-padding">
                        <div class="widget-content widget-content-two">
                            <table class="table table-bordered data-table table-striped wd-hover-btn wd-table-order-management">
                                <thead>
                                    <tr>
                                        <th class="wd-col-1">STT</th>
                                        <th class="wd-col-2">Mã đơn hàng</th>
                                        <th style="text-align:left">Tên khách hàng</th>
                                        <th class="wd-col-4">Giá trị đơn hàng</th>
                                        <th class="">Thời gian tạo</th>
                                        <th class="">Thời gian nhận hàng</th>
                                        <th class="wd-col-7">Trạng thái</th>
                                        <th class="wd-col-6">Thao tác</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $count=1;$sum=0;
                                    foreach ($paid_orders as $data) {
                                            $sum+=$data['Order']['sum'];?>
                                        <tr>
                                            <td><?php echo $count++?></td>
                                            <td><?php if($data['Order']['code']){echo $data['Order']['code'];}else{ echo $this->Currency->codeOrder($data['Order']['id']);}?></td>
                                            <td style="text-align:left"><?php echo $data['User']['fullname']?></td>
                                            <td><?php echo $this->Currency->formatCurrency($data['Order']['sum'])?> vnđ</td>
                                            <td><?php echo date('G:i d-m-Y',$data['Order']['created'])?></td>
                                            <td><?php echo $data['Order']['time']?></td>
                                            <td>
                                                <div class="control-group list-checkbox">
                                                    <div class="control-group">
                                                        <label class="control-label">
                                                            <input type="checkbox" id="check-paid-<?php echo $data['Order']['id']?>-2" name="radios" class="mtop" />
                                                            Đã nhận hàng
                                                        </label>
                                                    </div>
                                                </div>                                                              
                                            </td>
                                            <td>
                                                <ul class="wd-link-control">
                                                    <li><a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'order_edit', $data['Order']['id'], '?' => $_queries));?>" class="btn btn-mini">
                                                <i class="icon-edit"></i> <?php echo __d('system','Xem');?></a>
                                                </li>
                                                    <li class="wd-icon-2"><button type="button" id="<?php echo $data['Order']['id']?>" class="btn btn-mini btn-inverse check_paid"><i class="glyphicon icon-save "></i> Lưu</button></li>

                                                </ul>
                                            </td>
                                        </tr>
                                    <?php }?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12 statistics">
                            <p><i class="icon-list-alt"></i> Số lượng đơn hàng: <strong><?php echo ($count-1);?></strong></p>
                            <p><i class="icon-hand-right"></i> Tổng giá trị đơn hàng: <strong><?php echo $this->Currency->formatCurrency($sum) .'đ';?></strong></p>
                        </div>
                    </div>
                </div>
                <div id="tab4" class="tab-pane">
                    <div class="widget-box widget-content-no-padding">
                        <div class="widget-content widget-content-two">
                            <table class="table table-bordered data-table table-striped wd-hover-btn wd-table-order-management">
                                <thead>
                                    <tr>
                                        <th class="wd-col-1">STT</th>
                                        <th class="wd-col-2">Mã đơn hàng</th>
                                        <th style="text-align:left">Tên khách hàng</th>
                                        <th class="wd-col-4">Giá trị đơn hàng</th>
                                        <th class="">Thời gian tạo</th>
                                        <th class="">Thời gian nhận hàng</th>
                                        <th class="wd-col-6">Thao tác</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $count=1;$sum=0;
                                    foreach ($received_orders as $data) {
                                        $sum+=$data['Order']['sum'];?>
                                        <tr>
                                            <td><?php echo $count++?></td>
                                            <td><?php if($data['Order']['code']){echo $data['Order']['code'];}else{ echo $this->Currency->codeOrder($data['Order']['id']);}?></td>
                                            <td style="text-align:left"><?php echo $data['User']['fullname']?></td>
                                            <td><?php echo $this->Currency->formatCurrency($data['Order']['sum'])?> vnđ</td>
                                            <td><?php echo date('G:i d-m-Y',$data['Order']['created'])?></td>
                                            <td><?php echo $data['Order']['time']?></td>
                                            <td>
                                                <ul class="wd-link-control">
                                                    <li><a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'order_edit', $data['Order']['id'], '?' => $_queries));?>" class="btn btn-mini">
                                                <i class="icon-edit"></i> <?php echo __d('system','Xem');?></a>
                                                </li>
                                                </ul>
                                            </td>
                                        </tr>
                                    <?php }?>
                                    
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12 statistics">
                            <p><i class="icon-list-alt"></i> Số lượng đơn hàng: <strong><?php echo ($count-1);?></strong></p>
                            <p><i class="icon-hand-right"></i> Tổng giá trị đơn hàng: <strong><?php echo $this->Currency->formatCurrency($sum) .'đ';?></strong></p>
                        </div>
                    </div>
                </div>
                <div id="tab5" class="tab-pane">
                    <div class="widget-box widget-content-no-padding">
                        <div class="widget-content widget-content-two">
                            <table class="table table-bordered data-table table-striped wd-hover-btn wd-table-order-management">
                                <thead>
                                    <tr>
                                        <th class="wd-col-1">STT</th>
                                        <th class="wd-col-2">Mã đơn hàng</th>
                                        <th style="text-align:left">Tên khách hàng</th>
                                        <th class="wd-col-4">Giá trị đơn hàng</th>
                                        <th class="">Thời gian tạo</th>
                                        <th class="">Thời gian nhận hàng</th>
                                        <th class="wd-col-6">Thao tác</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $count=1;$sum=0;
                                    foreach ($invalid_orders as $data) {
                                            $sum+=$data['Order']['sum'];?>
                                        <tr>
                                            <td><?php echo $count++?></td>
                                            <td><?php if($data['Order']['code']){echo $data['Order']['code'];}else{ echo $this->Currency->codeOrder($data['Order']['id']);}?></td>
                                            <td style="text-align:left"><?php echo $data['User']['fullname']?></td>
                                            <td><?php echo $this->Currency->formatCurrency($data['Order']['sum'])?> vnđ</td>
                                            <td><?php echo date('G:i d-m-Y',$data['Order']['created'])?></td>
                                            <td><?php echo $data['Order']['time']?></td>
                                            <td>
                                                <ul class="wd-link-control">
                                                    <li><a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'order_edit', $data['Order']['id'], '?' => $_queries));?>" class="btn btn-mini">
                                                <i class="icon-edit"></i> <?php echo __d('system','Xem');?></a>
                                                </li>
                                                    <li class="wd-icon-2"><button data-target="#<?php echo $data['Order']['id']?>" data-toggle="modal" class="btn btn-mini"><i class="icon-remove"></i> <?php echo __d('system','Delete');?></button></li>
                                                </ul>
                                            </td>
                                        </tr>
                                    <?php }?>
                                </tbody>
                            </table>
                            <?php   foreach ($invalid_orders as $data) {?>
                            <div id="<?php echo $data['Order']['id']?>" class="modal hide">
                                <div class="modal-header">
                                    <button data-dismiss="modal" class="close" type="button">×</button>
                                    <h3>Thông báo</h3>
                                </div>
                                <div class="modal-body">
                                    <p>Bạn có chắc chắn xóa đơn hàng Mã số <?php echo $data['Order']['id']?> ?</p>
                                </div>
                                <div class="modal-footer">
                                    <a data-dismiss="modal" class="btn" href="#">Hủy </a>
                                    <a class="btn btn-danger" href="/admin/node/node/order_delete/<?php echo $data['Order']['id']?>">Xóa</a>
                                </div>
                            </div>
                            <?php }?>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12 statistics">
                            <p><i class="icon-list-alt"></i> Số lượng đơn hàng: <strong><?php echo ($count-1);?></strong></p>
                            <p><i class="icon-hand-right"></i> Tổng giá trị đơn hàng: <strong><?php echo $this->Currency->formatCurrency($sum) .'đ';?></strong></p>
                        </div>
                    </div>
                </div>
            </div>                            
        </div>						
        
    </div>	    
</div>
<?php         
    // echo $this->Form->hidden('task', array('id' => 'task', 'value' => ''));
    // echo $this->Form->end();
?>
<style type="text/css">
    .lbl-moved{text-decoration: underline;text-indent: initial;font-size: 16px;font-weight: bold;}
</style>
